#!/usr/bin/env perl 
use Getopt::Long;
use strict;

sub print_usage() {
    print "cat debug.log | analyzeMap.pl --move=<movenumber\n";
    print "\t\t --only_orders\n";
    print "\t\t --ant=x,y --ant=x1,y1\n";
    exit(-1);
}
my $move;
my @ants;
my $only_orders='';
my $result = GetOptions( "move=i",\$move,
                         "ant=s",\@ants,
                         "only_orders!",\$only_orders);
if (!$result) {
    print_usage();
}

if (!defined($move)) {
    
    print_usage();
}
my $nextmove = $move+1;
my $in_move = 0;
while(<STDIN>) {
    if ($_=~/turn $move/) {
        $in_move=1;
        print $_;
    }
    if (($in_move) && ($_=~/turn $nextmove/)) {
        print $_;
        last;
    }
    if ($in_move && $only_orders && ($_=~/Issuing order/)) {
        print $_;
    }
    elsif ($in_move && !$only_orders) {
        print $_;
    }
}
        
